<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>表单列表渲染</title>
        <{$showjs}>
        <link rel="stylesheet" type="text/css" href="/Plug-in/ext/resources/css/xtheme-slate.css" />
        <link rel="stylesheet" type="text/css" href="../css/main1.css" />
        <script type="text/javascript" src="/Plug-in/ext/Ext.grid.CheckColumn.js"></script>
        <script type="text/javascript" src="/Plug-in/ext/Ext.Store.Sort.js"></script>
        <script type="text/javascript" src="/Plug-in/ext/Ext.form.Property.js"></script>
		<script type="text/javascript" src="/Plug-in/jq/jquery.js"></script>
        <style type="text/css">
            .add{background:url(../img/add.gif) no-repeat 1px 2px !important;}
            .copy{background:url(../img/copy.gif) no-repeat 1px 2px !important;}
            .del{background:url(../img/del.gif) no-repeat 1px 2px !important;}
            .edit{background:url(../img/edit.gif) no-repeat 1px 2px !important;}
            .search{background:url(../img/find.gif) no-repeat 1px 2px !important;}
            .hidea{background:url(../img/arrow_out.png) no-repeat 1px 2px !important;}
            .hideb{background:url(../img/arrow_in.png) no-repeat 1px 2px !important;}
            .fsadd{background:url(../img/icon_extension.gif) no-repeat 1px 2px !important;}
            .fslist{background:url(../img/list_extensions.gif) no-repeat 1px 2px !important;}
            .real_time{background:url(../img/date_edit.png) no-repeat 1px 2px !important;}
            .exportExcel{background:url(../img/page_excel.png) no-repeat 1px 2px !important;}
            .x-plain{color:#fff;}
			.i_zd{background:url(../img/arrow_rotate_clockwise.png) no-repeat 1px 2px !important;}
            .x-check-group-alt {
                background: #D1DDEF;
                border-top:1px dotted #B5B8C8;
                border-bottom:1px dotted #B5B8C8;
            }
        </style>
        <script language="javascript">
			//分页数量
            var perpage = parseInt("<{if $smarty.get.limit == ''}>15<{else}><{$smarty.get.limit}><{/if}>");

            function gxzd(id,zd,xz){							
                Ext.Ajax.request({
                    waitMsg:'数据处理中...',
                    url:'./i.php',
                    method:'POST',
                    params:{
                        op:'gxzd',
                        id:id,
                        tname:'<{$table.tabname}>',
                        zd:zd,
                        xz:xz
                    },
                    success:function(response){
                        var bbb =Ext.query("button[class*='loading']");
                        bbb[0].click();

                    },
                    failure:function(response){
                        Ext.MessageBox.alert('警告',"无法连接数据库!");
                    }
		
                });
            }
            function tjpx(tid,zd){
                var pr=top.Ext.get('px'+tid+zd);
                if(pr){
                    pr.close();
                }
                top.xajax_loadUrl('排序-'+tid+'_'+zd,'./show1/px.php?&op=show&tid='+tid+'&zd='+zd,'516',top.Ext.getBody().getHeight()*3/5,false,'px'+tid+zd);
            }

            <!--
            Ext.onReady(function (){

                //信息提示选项   
                Ext.QuickTips.init();
				//将一些配置属性应用到此单态
                Ext.apply(Ext.QuickTips.getQuickTip(), {
                    showDelay: 50,
                    trackMouse: true,
                    dismissDelay: 0
                });

                Ext.form.Field.prototype.msgTarget = 'side';//设置提示信息位置为边上
                //信息提示选项end
                var myMask = new Ext.LoadMask(Ext.getBody(), {
                    msg: '请稍候...',
                    removeMask: true
                });
                //grid 复选栏控件
                var checkColumn = new Ext.grid.CheckColumn({
                    header: "Indoor",
                    dataIndex: 'indoor',
                    width: 55
                });
                //grid 复选栏控件end

                //ds 参数
                var data = {url : "./l.php" , method:'POST'};//异步参数
                var requestParams = {op : 'fy',tid:<{$tree.id}> ,bdtid:'<{$bdtid}>' , bdid :'<{$bdid}>',dbname:'<{$table.tabname}>'}; //请求参数,store 每次请求都发送的参数,可在这里设定,id gid sortid 等信息
                var sm = new Ext.grid.CheckboxSelectionModel();
                //cm 参数
                var cmCfg = [
                    //					checkColumn,
                    sm,//原样写就可以
                    {tooltip:'ID',header:'ID',dataIndex:'id',width:50,sortable:true,readOnly:true,renderer: function(v,p){p.attr+= "ext:qtip='"+ v + "'";return v;}},
                        <{section name=li loop=$xr}>
                        {id:'<{$xr[li].id}>',tooltip:'<{$xr[li].name}>',header:'<{$xr[li].name}>',dataIndex:'<{$xr[li].fname}>',width:<{$xr[li].wd}>,sortable:true<{if $xr[li].renderer neq ''}><{$config[li].renderer}><{else}><{if $xr[li].type != 'recommend' && $xr[li].type != 'fileup'}>,renderer: function(v,p){p.attr+= "ext:qtip='"+ v + "'";return v;}<{/if}><{/if}>}
                        <{if $smarty.section.li.index+1 < $xr|@count}>,<{/if}>
                        <{/section}>
                    ];

                //ds解析模型 用于ds 的reader
                var robj = [		
                    //	{name: 'indoor', type: 'bool'},
                    new Ext.grid.RowNumberer(),//原样写就可以
                    {name: 'id',type:'int'},
                        <{section name=li loop=$xr}>
                        {name:'<{$xr[li].fname}>'}
                        <{if $smarty.section.li.index+1 < $xr|@count}>,<{/if}>
                        <{/section}>
                    ];

                // ds reader
                var rd = new Ext.data.JsonReader({
                    totalProperty:'total',
                    root:'data',
                    id:'jsonreader'
                },robj);



                var ds = new Ext.data.Store({
                    proxy: new Ext.data.HttpProxy(data),
                    reader:rd,
                    baseParams:requestParams,
                    remoteSort:true,
                    sortInfo:{field :'id',direction:'DESC'}
                });


                var cm = new Ext.grid.ColumnModel(cmCfg);


                var advSearchForm=new Ext.FormPanel({
                    id:'advSearchForm',
                    name:'advSearchForm',
                    labelWidth:65,
                    border:false,
                    autoScroll:true,
                    autoHight:true,
                    labelAlign:'right',
                    bodyStyle:'padding:5px 0',
                    buttunAlign:'left',
                    layout:'form',
                    plain:true,
                    frame:true,
                    items:[
                        {
                            xtype:'hidden',
                            name: 'tid',
                            value:'<{$tree.id}>'
                        },{
                            xtype:'hidden',
                            name: 'bdtid',
                            value:'<{$bdtid}>'
                        },{
                            xtype:'hidden',
                            name: 'bdid',
                            value:'<{$bdid}>'
                        }
                            <{section name=li loop=$js}>
                            ,<{$js[li]}>
                            <{/section}>
                        ,{
                            layout:'column',
                            items:[{
                                    columnWidth:.28,
                                    layout:'form',
                                    items:[{
                                            xtype:'combo',
                                            id:'order_field_id',
                                            hiddenName:'sort',
                                            fieldLabel:'排序',
                                            width:100,
                                            store : new Ext.data.JsonStore({
                                                autoLoad:false,
                                                url:'l.php?op=getOrderField&tid=<{$smarty.get.tid}>',
                                                root:'data',
                                                fields:['fname','name']
                                            }),
                                            triggerAction:'all',
                                            displayField:'name',
                                            valueField:'fname',
                                            mode:'remote'
                                    }]
                                },{
                                    columnWidth:.4,
                                    layout:'form',
                                    items:[{
                                            xtype:'combo',
                                            id:'order_type_id',
                                            hiddenName:'dir',
                                            fieldLabel:'',
                                            hideLabel:true,
                                            labelSeparator:'',
                                            width:80,
                                            store : new Ext.data.SimpleStore({
                                                fields:['value','label'],
                                                data:[['DESC','倒序'],['ASC','正序']]
                                            }),
                                            triggerAction:'all',
                                            displayField:'label',
                                            valueField:'value',
                                            mode:'local',
                                            value:'DESC'
                                    }]
                                }]
                        }],
                    buttons:[
                        {text:'过滤',iconCls:'search',handler:function (){
				
                                /*					for (elm in advSearchForm.getForm().getValues(false)) {
                                alert(elm); 
                                }   
                                 */
                                var searchobj=advSearchForm.getForm().getValues(false);
                                //			alert(advSearchForm.getForm().getValues(true));
                                searchobj.start=0;
                                searchobj.limit=perpage;
                                //alert(searchobj);
                                ds.load({
                                    params:searchobj
                                });
                                //清除已点击的grid的排序
                                if(Ext.getCmp('order_field_id').getValue()){
                                    //advSearchForm.getView().refresh(true);
                                    //获取当前排序的列
                                    var sortedColumn = cm.getColumnsBy(function(c){
                                        return c.dataIndex == ds.getSortState().field;
                                    });
                                    sortedColumn[0].type = 'int';
                                    //更新排序
                                    ds.sort(Ext.getCmp('order_field_id').getValue(),Ext.getCmp('order_type_id').getValue());
                                    //alert(sortedColumn[0].sortable)
                                    //grid.getView().refresh(true);
                                }
                                //advSearchwin.hide();
                            }},
                        {text:'清空条件',handler:function (){
                                advSearchForm.form.reset();
                                //advSearchwin.hide();
                            }}
                    ]
                });
                var advSearchwin=new Ext.Window({
                    title:'高级搜索',
                    id:'advSearchwin',
                    collapsible : true,
                    /*			tools : [ 
                        {id:'toggle'}, 
                        {id:'close'}, 
                        {id:'maximize'} 
                       ], */
                    width:700,
                    autoHight:true,
                    closeAction:'hide',
                    plain:true,
                    items:advSearchForm
                });



                var adstatus=0;
                function searchHandeler(){
                    advSearchwin.show();
                    adstatus=1
                }

                function delHandeler(){
                    if(grid.selModel.getCount()==1){
                        Ext.MessageBox.confirm("操作确认","你确认删除当前选择项目?",delTask);
                    }else if(grid.selModel.getCount()>1){
                        Ext.MessageBox.confirm("警告","你确认删除选中的项目?",delTask);
                    }else{
                        Ext.MessageBox.alert('消息',"你没有选中项目");
                    }  
                }
                function editHandeler(){
                    if(grid.selModel.getCount()==1){
                        var selections = grid.selModel.getSelections();
                        var pr=top.Ext.get('adddata<{$tree.id}>');
                        if(pr){
                            pr.close();
                        }
                        parent.xajax_loadUrl('编辑<{$tree.title}>[<{$tree.id}>]_<{$table.name}>[<{$table.tabname}>]数据','./show1/i.php?op=add&tid=<{$tree.id}>&id='+selections[0].json.id,top.Ext.getBody().getWidth(),top.Ext.getBody().getHeight(),false,'adddata<{$tree.id}>');
            

                        /*	Ext.Ajax.request({
                    waitMsg:'数据加载中...',
                    url:'../action/getaline.php',
                    method:'POST',
                    params:{
                        op:'load',
                        id:selections[0].json.id,
                        dbname:'yuding'
                    },
                    success:function(response){
                     var result = Ext.util.JSON.decode(response.responseText);
                    parent.xajax_addForm(1);
                    //	loaddate(result);
                    },
                    failure:function(response){
                        Ext.MessageBox.alert('警告',"无法连接数据库!");
                    }

                });*/
		
                    }else if(grid.selModel.getCount()>1){
                        Ext.MessageBox.alert("提示","本操作无法批量完成");
                    }else{
                        Ext.Msg.alert("提示消息","请选择一行数据然后才能够编!");return false;
                    }
                }
                function fsadd(fstid,title,url,id){
                    var pr=top.Ext.get('adddata'+fstid);
                    if(pr){
                        pr.close();
                    }
                    top.xajax_loadUrl('添加绑定数据-'+title,url+id,top.Ext.getBody().getWidth(),top.Ext.getBody().getHeight(),false,'adddata'+fstid);
                }
                function fslist(fstid,title,url,id){
                    var pr=top.Ext.get('list'+fstid);
                    if(pr){
                        pr.close();
                    }
                    top.xajax_loadUrl('浏览绑定数据-'+title,url+id,top.Ext.getBody().getWidth(),top.Ext.getBody().getHeight(),false,'list'+fstid);
                }
                /**
                 *添加新标签
                 */
                function createTab(id,title,url){
                    var tab = top.center.getItem(id);
                    if(tab == undefined){
                        tab = top.center.add({ 
                            id: id, 
                            title : title, 
                            closable:true,
                            frame:true,
                            html: '<iframe src="'+url+'" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>'
                        });
                    }
                    top.center.setActiveTab(tab);
                }

                //删除处理
                function delTask(btn){
                    if (btn=='yes'){
                        var selections = grid.selModel.getSelections();
                        var prez = [];
                        for(i = 0; i< grid.selModel.getCount(); i++){
                            prez.push(selections[i].json.id);
                        }

                        var encoded_array= Ext.encode(prez);

                        Ext.Ajax.request({
                            waitMsg:'正在操作',
                            url:'./l.php',
                            method:'POST',
                            params:{
                                op:'del',
                                ids:encoded_array,
                                dbname:'<{$table.tabname}>',
                                tid:'<{$tree.id}>'
                            },
                            success:function(response){
                                Ext.MessageBox.alert('消息',"数据删除成功！");
                                ds.reload();
                                grid.refresh();
                            },
                            failure:function(response){
                                Ext.MessageBox.alert('警告',"无法连接数据库!");
                            }

                        });

                    }
                }
                //删除end
                //edit
                var oneTbar=new Ext.Toolbar({   
                    items:[   
                        {text:'当前页利润：<font color=red>45</font>元',id:'dq'},   
                        {text:'总利润：<font color=red>145</font>元',id:'zong'}
                    ]     
                });   

                //标题搜索
                var sbar=new Ext.FormPanel({
                    baseCls: 'x-plain',
                    bodyStyle:'padding:5px 0 0 0',
                    defaults: {width:150},
                    labelWidth:80,
                    defaultType: 'textfield',
                    items: [{
                            fieldLabel: '标题搜索',
                            id:'tt',
                            name: 'title'
                        }]
                });
                var searObj= {
                    text: '搜索',
                    handler:function(){
                        ds.load({
                            params:{
                                title:Ext.get('tt').dom.value,start:0,limit:perpage
                            }
                        })
                    }
                };
                //标题搜索end

				var pbar = new Ext.PagingToolbar({
                    id:'bbar',
                    pageSize: perpage,
                    store: ds,
                    displayInfo: true,
                    displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
                    emptyMsg: "没有记录",
                    items : ['-',{xtype:"button",text:"转到",iconCls:"i_zd",handler:function(){
                                if(isNaN($('#bbar input').val())){
                                    alert("请输入正确的页码数！");
                                    return false;
                                }else{
                                    ds.load({
                                        params:{
                                            start:perpage*($('#bbar input').val()-1),
                                            limit:perpage
                                        }
                                    })
                                }
                            }}]
                })
                
                var grid = new Ext.grid.GridPanel({
                    el:'cms-grid-el',
                    id:'cms-grid-id',
                    //		plugins:checkColumn,
                    clicksToEdit:1,
                    ds:ds,
                    cm:cm,
                    sm:sm,//selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),
                    tbar: [
                        sbar,
                        searObj,
                        new Ext.Toolbar.Separator(),
                        {text:'高级d搜索',iconCls:'search',tooltip:'高级搜索',handler:searchHandeler}<{if ($tree.id|getright:"u")}>,
                        new Ext.Toolbar.Separator(),
                        {text:'编辑',iconCls:'edit',handler:editHandeler}<{/if}>,
                        new Ext.Toolbar.Separator()<{if ($tree.id|getright:"c")}>,
                        {text:'添加',iconCls:'add',handler:function(){
                                var pr=top.Ext.get('adddata<{$tree.id}>');
                                if(pr){
                                    pr.close();
                                }
                                top.xajax_loadUrl('向<{$tree.title}>[<{$tree.id}>]_<{$table.name}>[<{$table.tabname}>]添加数据','./show1/i.php?op=add&tid=<{$tree.id}>&bdtid=<{$bdtid}>&bdid=<{$bdid}>',top.Ext.getBody().getWidth(),top.Ext.getBody().getHeight(),false,'adddata<{$tree.id}>');
                            }}<{/if}><{if ($tree.id|getright:"d")}>,
                        /*			new Ext.Toolbar.Separator(),
                    {text:'批量操作',iconCls:'copy'},
                         */			new Ext.Toolbar.Separator(),
                        {text:'删除',iconCls:'del',handler:delHandeler}<{/if}>,
                        new Ext.Toolbar.Separator(),
                        {text:'<font color=yellow><b>隐藏周边</b></font>',iconCls:'hidea',handler:function (){
                                if(!window.top.west.collapse(true)){
                                    window.top.west.expand(false);
                                    this.setIconClass('hidea');
                                    this.setText("<font color=yellow><b>隐藏周边</b></font>");
                                    this.blur;
                                }else{
                                    this.setIconClass('hideb');
                                    this.setText("<font color=red><b>显示周边</b></font>");
                                    this.blur;
                                }
                                if(!window.top.north.collapse(true)){
                                    window.top.north.expand(false);
                                }

                            }},
                        new Ext.Toolbar.Separator(),
                        {text:'刷新',iconCls:'i_czxt',handler:function (){
                                //window.location.reload();
                                ds.reload();
                            }}
                        <{if $tree_config.excelExport == 1}>
                        ,new Ext.Toolbar.Separator()
                        ,{text:'导出',iconCls:'exportExcel',handler:function (){
                                exportExcel('<{$smarty.get.tid}>');
                            }}
                        <{/if}>
                        ,new Ext.Toolbar.Separator()
                        ,new Ext.FormPanel({
                            baseCls: 'x-plain',
							bodyStyle:'padding:5px 0 0 0',
                            labelWidth:80,
                            width:150,
                            items: [{
                                    xtype:'textfield',
									width:25,
                                    fieldLabel: '每页显示数量',
                                    fieldClass :'perpageFieldClass',
                                    id:'perpageFieldId',
                                    selectOnFocus :true,
                                    value:perpage,
                                    listeners:{
                                        change:function(a,b,c){
                                            //ds.load({params:{limit:b}});
											window.location = "./l.php?op=list&tid=<{$smarty.get.tid}>&limit="+b;
                                        }
                                    }
                                }]
                        })
                    ],
                    /*		listeners   : {   
                       'render': function(){   
                            oneTbar.render(this.bbar);      //add one tbar   
                        }   
                    },
                     */		
                    bbar: pbar,
                    //autoWidth:true,
                    width:Ext.getBody().getWidth(),
                    autoHeight:true,
                    autoShow:true,
                    frame:true,
                    //		autoExpandColumn:true,
                    autoDestroy:true,
                    title:'信息浏览',
                    cls:'',//extra css 
                    loadMask:{msg:"正在加载数据..."},
                    viewConfig: {
                        forceFit:true,
                        scrollOffset:2, // Grid按钮将不会显示上下滚动条
						layout : function() {      
							if (!this.mainBody) {      
								return; // not rendered      
							 }      
							var g = this.grid;      
							var c = g.getGridEl();      
							var csize = c.getSize(true);      
							var vw = csize.width;      
							if (!g.hideHeaders && (vw < 20 || csize.height < 20)) { // display:      
								// none?      
								return;      
							 }      
							if (g.autoHeight) {      
								if (this.innerHd) {      
									this.innerHd.style.width = (vw) + 'px';      
								 }      
							 } else {      
								this.el.setSize(csize.width, csize.height);      
								var hdHeight = this.mainHd.getHeight();      
								var vh = csize.height - (hdHeight);      
								this.scroller.setSize(vw, vh);      
								if (this.innerHd) {      
									this.innerHd.style.width = (vw) + 'px';      
								 }      
							 }      
							if (this.forceFit) {      
								if (this.lastViewWidth != vw) {      
									this.fitColumns(false, false);      
									this.lastViewWidth = vw;      
								 }      
							 } else {      
								this.autoExpand();      
								this.syncHeaderScroll();      
							 }      
							this.onLayout(vw, vh);      
						 }
                    }
                    //		default:{width:50}
                });

                ds.load({params:{start:0,limit:perpage}});
                grid.render();
                //alert(grid.getGridEl().getSize().width);
                grid.on('columnresize',function(columnIndex,newSize){
                    var column_id=cm.getColumnId(columnIndex);
                    myMask.show();
                    Ext.Ajax.request(
                    {
                        waitMsg:'正在提交....',
                        method:'POST',
                        params:{op:'width_change',id:column_id,width:newSize},
                        url:'l.php',
                        success:function(form, action) {
                            myMask.hide();
                        },
                        failure: function(form, action) {
                        }
                    }
                );
                });
	
                    <{if ($tree.id|getright:"u")}> grid.on('celldblclick', editHandeler); <{else}>
                    grid.on('celldblclick', function(){Ext.MessageBox.alert('警告','没有编辑权限')});
                    <{/if}>

                    ds.on('beforeload',function(){
                    Ext.apply(
                    this.baseParams,
                    {
                        <{section name=li loop=$ckbox}>
                        '<{$ckbox[li]}>':'',<{/section}>
                        });
                    //alert(advSearchForm.getForm().getValues(false));
                    if(adstatus!=0){
                        Ext.apply(
                        this.baseParams,
                        advSearchForm.getForm().getValues(false));
	
                    }

                });


                grid.on("rowcontextmenu",function(grid,rowIndex,e){ 
                    e.preventDefault();if(rowIndex<0){return;} 
                    var treeMenu = new Ext.menu.Menu 
                    ([ 
                            <{if ($tree.id|getright:"c")}>{xtype:"button",text:"添加",iconCls:"add",pressed:true,handler:function(){
                                var pr=top.Ext.get('adddata<{$tree.id}>');
                                if(pr){
                                    pr.close();
                                }
                                top.xajax_loadUrl('向<{$tree.title}>[<{$tree.id}>]_<{$table.name}>[<{$table.tabname}>]添加数据','./show1/i.php?op=add&tid=<{$tree.id}>&bdtid=<{$bdtid}>&bdid=<{$bdid}>',top.Ext.getBody().getWidth(),top.Ext.getBody().getHeight(),false,'adddata<{$tree.id}>');
                            }}, <{/if}>
                            {xtype:"button",text:"刷新",iconCls:"i_czxt",pressed:true,handler:function(){
                                window.location.reload();
                            }}<{if ($tree.id|getright:"d")}>, 
                        {xtype:"button",text:"删除",iconCls:"del",pressed:true, handler:function(){
                                var record = grid.getStore().getAt(rowIndex); 
                                Ext.Ajax.request({
                                    waitMsg:'正在操作',
                                    url:'./l.php',
                                    method:'POST',
                                    params:{
                                        op:'del',
                                        tid:'<{$tree.id}>',
                                        ids:"["+record.data.id+"]",
                                        dbname:'<{$table.tabname}>'
                                    },
                                    success:function(response){
                                        Ext.MessageBox.alert('消息',"数据删除成功！");
                                        ds.reload();
                                        grid.refresh();
                                    },
                                    failure:function(response){
                                        Ext.MessageBox.alert('警告',"无法连接数据库!");
                                    }

                                });
                            }}<{/if}><{$fstree}> 
                        ]); 
                    treeMenu.showAt(e.getPoint()); 
                }); 


            });
            //-->
        </script>
        <script language="javascript" type="text/javascript" src="/Plug-in/My97/WdatePicker.js"></script>
        <script language="javascript" type="text/javascript" src="../js/exportExcel.js"></script>

    </head>

    <body>
        <div id="cms-grid-el" style="width:100%;overflow:auto;">

        </div>
    </body>
</html>